import request from '@/utils/request'

// 销售订单开始---------------------------

export function getSaleOrderCustomer() {
  return request({
    url: '/sale/sale_order_customer/',
    method: 'GET'
  })
}


export function getSaleOrderMaxCode(params) {
  return request({
    url: '/base/sale_order_code/',
    method: 'GET',
    params
  })
}

export function getSaleOrderCodeList(params) {
  return request({
    url: '/sale/sale_order_list/',
    method: 'GET',
    params
  })
}

export function getSaleOrderDetailList(params) {
  return request({
    url: '/sale/sale_order_detail_list/',
    method: 'GET',
    params
  })
}

export function getSaleOrders(params) {
  return request({
    url: '/sale/sale_order/',
    method: 'GET',
    params
  })
}


export function addSaleOrder(data) {
  return request({
    url: '/sale/sale_order/',
    method: 'POST',
    data
  })
}


export function updateSaleOrder(data) {
  return request({
    url: `/sale/sale_order/${data.id}/`,
    method: 'PUT',
    data
  })
}

export function delSaleOrder(id) {
  return request({
    url: `/sale/sale_order/${id}/`,
    method: 'DELETE',
  })
}

export function delSaleOrders(data) {
  return request({
    url: '/sale/sale_order/batch_delete/',
    method: 'DELETE',
    data
  })
}

export function delSaleOrderDetails(data) {
  return request({
    url: `/sale/sale_order_detail/batch_delete/`,
    method: 'DELETE',
    data
  })
}

// 销售订单结束----------------------------

// 销售收款单开始---------------------------

export function getSaleReceiptMaxCode() {
  return request({
    url: '/base/sale_receipt_code/',
    method: 'GET'
  })
}

export function getSaleReceipts(params) {
  return request({
    url: '/sale/sale_receipt/',
    method: 'GET',
    params
  })
}

export function addSaleReceipt(data){
  return request({
    url: 'sale/sale_receipt/',
    method: 'POST',
    data
  })
}

export function updateSaleReceipt(data){
  return request({
    url: `/sale/sale_receipt/${data.id}/`,
    method: 'PUT',
    data
  })
}

export function delSaleReceipt(id) {
  return request({
    url: `/sale/sale_receipt/${id}/`,
    method: 'DELETE',
  })
}

export function delSaleReceipts(data) {
  return request({
    url: '/sale/sale_receipt/batch_delete/',
    method: 'DELETE',
    data
  })
}

export function delSaleReceiptDetails(data) {
  return request({
    url: `/sale/sale_receipt_detail/batch_delete/`,
    method: 'DELETE',
    data
  })
}

// 销售收款单结束----------------------------

//销售出库对账单
export function getSaleBill(params){
  return request({
    url: 'sale/sale_bill/',
    method: 'GET',
    params
  })
}

export function downloadSaleBill(params){
  return request({
    url: 'sale/sale_bill/',
    method: 'GET',
    params,
    responseType: 'blob'
  })
}

export function getRecvAccounts(params){
  return request({
    url: 'sale/recv_account/',
    method: 'GET',
    params
  })
}

export function getProfits(params){
  return request({
    url: 'sale/profit/',
    method: 'GET',
    params
  })
}
